var getColor = function () {
    return "green";
}
var b;
var marker = new Map();
var lable = new Map();

function showPoly(a1, b1) {
    //去掉点击某个点弹出东西
    b = new BMap.Map("allmap", {enableMapClick: false});
    // {"cameraID":"1211828133370216450","cameraName":"创新中心北","lng":"103.907065","lat":"30.701563"}
    b.centerAndZoom(new BMap.Point(a1[0].lng, a1[0].lat), b1);
    b.enableScrollWheelZoom(true);
    for (var c = 0; c < a1.length; c++) {
        var i = new BMap.Marker(new BMap.Point(a1[c].lng, a1[c].lat));
        //i.setTitle(a1[c].cameraName);
        var k = new BMap.Label("arms", {
            //距离点的左右位置和上下位置
            offset: new BMap.Size(0, 28)
        });
        k.setStyle({
            color: "white",
            border: "0px",
           // backgroundColor: "0.000000000001",  //通过这个方法，去掉背景色
            backgroundColor: "#9DB7F2",  //通过这个方法，去掉背景色
            fontSize: "12px",
            height: "20px",
            // border:"1px solid black",
            lineHeight: "20px"
        });
        k.setContent("&nbsp;&nbsp;"+a1[c].cameraName+"&nbsp;&nbsp;");
        b.addOverlay(i);
        i.setLabel(k);
        //  i.addEventListener("mouseover", function () {
        //      this.setLabel(k);
        // });
        // i.addEventListener("mouseout",function () {
        //     if(k!=undefined)
        //     {
        //         this.getMap().removeOverlay(k);
        //     }
        // });
        marker.set(a1[c].cameraID, i);
    }
}

function showArm(jsonval) {
    marker.get(jsonval.data.cameraId).getMap().removeOverlay(lable.get(jsonval.data.cameraId));
   // var randomWidthNum=Math.floor(Math.random()*50+1);
  //  var randomHeightNum=Math.floor(Math.random()*50+1);
    var randomWidthNum=0;
     var randomHeightNum=0;
    var k = new BMap.Label("arms" + jsonval.data.cameraId, {
        //距离点的左右位置和上下位置
        offset: new BMap.Size(-105-randomWidthNum, -115+randomHeightNum)
    });
    var str = "<div class='msg' id='msgContent" + jsonval.data.cameraId + "'>\n" +
        "    <div class='msg_left' >\n" +
        // "       <img id='msgContent_img1'  src='"+jsonval.data.bgImg+"' /><br/>" +
        "<canvas width=120 height=120  class='imgicon' id='imgicon" + jsonval.data.cameraId + "'></canvas><br/>" +
        // "<img src='CjMKy14WrK-AKJyzAABtz18SQHU762.jpg' style='position: absolute;clip: rect(70px,323px,218px,173px);width: 540px;height: 303px;'>"+
        "       <img id='msgContent_img2" + jsonval.data.cameraId + "' src='" + jsonval.data.faceUrl + "' />" +
        "    </div>\n" +
        "    <div class='msg_right'>\n" +
        "        <div class='msg_right_box'>\n" +
        "            姓&nbsp;&nbsp;&nbsp;名：<span id='msgContent_name" + jsonval.data.cameraId + "' title='"+jsonval.data.name+"'>" + jsonval.data.name + "</span>\n" +
        "        </div>\n" +
        "        <div class='msg_right_box'>\n" +
        "            性&nbsp;&nbsp;&nbsp;别：<span id='msgContent_sex" + jsonval.data.cameraId + "'>" + jsonval.data.sex + "</span>\n" +
        "        </div>\n" +
        "        <div class='msg_right_box'>\n" +
        "            人像库：<span id='msgContent_lib" + jsonval.data.cameraId + "'>" + jsonval.data.libName + "</span>\n" +
        "        </div>\n" +
        "         <div class='msg_right_box' id='msgContent_region" + jsonval.data.cameraId + "'>\n" +
        "           比&nbsp;&nbsp;&nbsp;分：<span id='msgContent_region" + jsonval.data.score + "' title='" + jsonval.data.score + "'>" + jsonval.data.score + "</span>\n" +
        "       </div>\n" +
        "        <div class='msg_right_box'>\n" +
        "            时&nbsp;&nbsp;间：<span id='msgContent_time" + jsonval.data.cameraId + "' title='" + jsonval.data.time + "'>" + jsonval.data.time + "</span>\n" +
        "        </div>" +
        "    </div>\n" +
        "</div>";
    k.setContent(str);
    k.setStyle({
        color: "#000",
        border: "0px",
        backgroundColor: "0.000000000001",  //通过这个方法，去掉背景色
        fontSize: "12px",
        height: "20px",
        lineHeight: "20px"
    });
    k.addEventListener("click", function () {
        alert("详细数据展示一个窗体：" + this.getPosition().lng + "," + this.getPosition().lat)
    });
    marker.get(jsonval.data.cameraId).setLabel(k);
    lable.set(jsonval.data.cameraId, k);
    var i = 0;
        var canvas= document.getElementById("imgicon"+jsonval.data.cameraId);
        var cxt = canvas.getContext("2d");
        cxt.clearRect(0,0,120,120);
        // //绘制图片
        var img = new Image();
        img.src = jsonval.data.bgImg;
        img.onload = function() {
            cxt.drawImage(img,jsonval.data.positionVO.x,jsonval.data.positionVO.y,jsonval.data.positionVO.w,jsonval.data.positionVO.h,0,0,120,120);
        }
    var timer = setInterval(function () {
        document.getElementById("notice").play();
        if (i % 2 == 0) {
            $("#msgContent" + jsonval.data.cameraId).removeClass("msg_bg_blue");
            $("#msgContent" + jsonval.data.cameraId).addClass("msg_bg_red");
        } else {
            $("#msgContent" + jsonval.data.cameraId).removeClass("msg_bg_red");
            $("#msgContent" + jsonval.data.cameraId).addClass("msg_bg_blue");
        }
        if (i > 10) {
            $("#msgContent" + jsonval.data.cameraId).removeClass("msg_bg_red", "msg_bg_blue");
            clearInterval(timer);
        }
        i++;
    }, 500)

    // alert("#msgContent"+jsonval.data.cameraId);
    // $("#msgContent"+jsonval.data.cameraId).show()
    // // var json={"code":200,"message":"成功","cmd":"WARNING","data":{"bgImg":"http://10.51.10.203:32080/g10203/M00/40/C1/CjMKy14ULjyADahlAAEjVYElPnw887.jpg","positionVO":{"x":199,"y":209,"w":25,"h":34},"score":0.81317765,"time":"2020-01-07 15:07:48","faceUrl":"http://10.51.10.201:9001/middleware/20191227/787a39d0ee114a68b627812153222bcd.jpg","name":"7","sex":"男","idCard":"150981198409254695","age":35,"taskId":"1211831416948211713","taskName":"小会议室走廊","taskType":"3","libName":"10000人像库","libId":"1210121197004161026"}};
    // if(jsonval.code==200)
    // {
    //     $("#msgContent"+jsonval.data.cameraId).show();
    //     $("#msgContent_img1"+jsonval.data.cameraId).attr("src",jsonval.data.bgImg);
    //     $("#msgContent_img2"+jsonval.data.cameraId).attr("src",jsonval.data.faceUrl);
    //     $("#msgContent_name"+jsonval.data.cameraId).html(jsonval.data.name);
    //     $("#msgContent_sex"+jsonval.data.cameraId).html(jsonval.data.sex);
    //     $("#msgContent_lib"+jsonval.data.cameraId).html(jsonval.data.libName);
    //     $("#msgContent_time"+jsonval.data.cameraId).html(jsonval.data.time);
    //
    // }
}